/**
 @file ctc_scl.h

 @date 2013-02-21

 @version v2.0

 The file define api struct used in SCL.
*/

#ifndef _CTC_SCL_H_
#define _CTC_SCL_H_

#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/

#include "ctc_const.h"
#include "ctc_field.h"
#include "ctc_xdata.h"

/****************************************************************
*
* Defines and Macros
*
****************************************************************/


/****************************************************************
*
* Data Structures
*
****************************************************************/

enum  ctc_scl_global_e
{
    CTC_SCL_MIN_USER_ENTRY_ID = 0,                      /**< [GB.GG.D2.TM.TMM.AT] Min user entry id */
    CTC_SCL_MAX_USER_ENTRY_ID = 0x7FFFFFFF,             /**< [GB.GG.D2.TM.TMM.AT] Max user entry id */
    CTC_SCL_GROUP_ID_MIN_NORMAL = 0,                    /**< [GB.GG.D2.TM.TMM.AT] Min normal group id */
    CTC_SCL_GROUP_ID_MAX_NORMAL = 0x7FFFFFFF,           /**< [GB.GG.D2.TM.TMM.AT] Max normal group id */
    CTC_SCL_KEY_SIZE_SINGLE = 0,                        /**< [GG.D2.TM.TMM.AT] Ipv4 tcam key use single size */
    CTC_SCL_KEY_SIZE_DOUBLE = 1                         /**< [GG.D2.TM.TMM.AT] Ipv4 tcam key use double size */
};
typedef enum ctc_scl_global_e ctc_scl_global_t;

/* Below groups are created already. just use it . */
/** @brief  SCL hash group id */
enum ctc_scl_group_id_rsv_e
{
    CTC_SCL_GROUP_ID_HASH_PORT = 0xFFFF0001,                /**< [GB.GG.D2.TM.TMM.AT] Group id of hash port group */
    CTC_SCL_GROUP_ID_HASH_PORT_CVLAN = 0xFFFF0002,          /**< [GB.GG.D2.TM.TMM.AT] Group id of hash port cvlan group */
    CTC_SCL_GROUP_ID_HASH_PORT_SVLAN = 0xFFFF0003,          /**< [GB.GG.D2.TM.TMM.AT] Group id of hash port svlan group */
    CTC_SCL_GROUP_ID_HASH_PORT_2VLAN = 0xFFFF0004,          /**< [GB.GG.D2.TM.TMM.AT] Group id of hash port double vlan group */
    CTC_SCL_GROUP_ID_HASH_PORT_CVLAN_COS = 0xFFFF0005,      /**< [GB.GG.D2.TM.TMM.AT] Group id of hash port cvlan cos group */
    CTC_SCL_GROUP_ID_HASH_PORT_SVLAN_COS = 0xFFFF0006,      /**< [GB.GG.D2.TM.TMM.AT] Group id of hash port svlan cos group */
    CTC_SCL_GROUP_ID_HASH_MAC = 0xFFFF0007,                 /**< [GB.GG.D2.TM.TMM.AT] Group id of hash mac group */
    CTC_SCL_GROUP_ID_HASH_PORT_MAC = 0xFFFF0008,            /**< [GB.GG.D2.TM.TMM.AT] Group id of hash port mac group */
    CTC_SCL_GROUP_ID_HASH_IPV4 = 0xFFFF0009,                /**< [GB.GG.D2.TM.TMM.AT] Group id of hash ipv4 group */
    CTC_SCL_GROUP_ID_HASH_PORT_IPV4 = 0xFFFF000A,           /**< [GB.GG.D2.TM.TMM.AT] Group id of hash port ipv4 group */
    CTC_SCL_GROUP_ID_HASH_IPV6 = 0xFFFF000B,                /**< [GB.GG.D2.TM.TMM.AT] Group id of hash ipv6 group */
    CTC_SCL_GROUP_ID_HASH_L2 = 0xFFFF000C,                  /**< [GB.GG.D2.TM.TMM.AT] Group id of hash layer 2 group */
    CTC_SCL_GROUP_ID_HASH_PORT_IPV6 = 0xFFFF000D,           /**< [GG.D2.TM.TMM.AT] Group id of hash port ipv6 group */
    CTC_SCL_GROUP_ID_HASH_MAX = 0xFFFF000E,                 /**< [GB.GG.D2.TM.TMM.AT] Max group id of hash group */
    CTC_SCL_GROUP_ID_TCAM0 = CTC_SCL_GROUP_ID_HASH_MAX,     /**< [D2.TM.TMM.AT] Group id of TCAM 0 */
    CTC_SCL_GROUP_ID_TCAM1 = 0xFFFF000F,                    /**< [D2.TM.TMM.AT] Group id of TCAM 1 */
    CTC_SCL_GROUP_ID_TCAM2 = 0xFFFF0010,                    /**< [TM.TMM.AT] Group id of TCAM 2 */
    CTC_SCL_GROUP_ID_TCAM3 = 0xFFFF0011,                    /**< [TM.TMM.AT] Group id of TCAM 3 */
    CTC_SCL_GROUP_ID_HASH0 = 0xFFFF0012,                    /**< [D2.TM.TMM.AT] Group id of HASH 0 */
    CTC_SCL_GROUP_ID_HASH1 = 0xFFFF0013,                    /**< [D2.TM.TMM.AT] Group id of HASH 1 */
    CTC_SCL_GROUP_ID_RSV_MAX                                /**< [GB.GG.D2.TM.TMM.AT] Max group id of reserved group */
};
typedef enum ctc_scl_group_id_rsv_e ctc_scl_group_id_rsv_t;

/** @brief  SCL Key Type */
enum ctc_scl_key_type_e
{
    CTC_SCL_KEY_TCAM_VLAN,                              /**< [GB.GG] Tcam vlan key */
    CTC_SCL_KEY_TCAM_MAC,                               /**< [GB.GG.D2.TM.TMM.AT] Tcam mac key */
    CTC_SCL_KEY_TCAM_IPV4,                              /**< [GB.GG.D2.TM.TMM.AT] Tcam ipv4 key */
    CTC_SCL_KEY_TCAM_IPV4_SINGLE,                       /**< [D2.TM.TMM.AT] Tcam ipv4 single key */
    CTC_SCL_KEY_TCAM_IPV6,                              /**< [GB.GG.D2.TM.TMM.AT] Tcam ipv6 key */
    CTC_SCL_KEY_TCAM_IPV6_SINGLE,                       /**< [D2.TM.TMM.AT] Tcam ipv6 single key */
    CTC_SCL_KEY_TCAM_UDF,                               /**< [TM.TMM.AT] Tcam udf key */
    CTC_SCL_KEY_TCAM_UDF_EXT,                           /**< [TM.TMM.AT] Tcam udf extend key */
    CTC_SCL_KEY_TCAM_UDF_QUAD,                          /**< [TMM.AT] Tcam udf quad key */
    CTC_SCL_KEY_HASH_PORT,                              /**< [GB.GG.D2.TM.TMM.AT] Hash port key */
    CTC_SCL_KEY_HASH_PORT_CVLAN,                        /**< [GB.GG.D2.TM.TMM.AT] Hash port cvlan key */
    CTC_SCL_KEY_HASH_PORT_SVLAN,                        /**< [GB.GG.D2.TM.TMM.AT] Hash port svlan key */
    CTC_SCL_KEY_HASH_PORT_2VLAN,                        /**< [GB.GG.D2.TM.TMM.AT] Hash port double vlan key */
    CTC_SCL_KEY_HASH_PORT_CVLAN_COS,                    /**< [GB.GG.D2.TM.TMM.AT] Hash port  cvlan cos key */
    CTC_SCL_KEY_HASH_PORT_SVLAN_COS,                    /**< [GB.GG.D2.TM.TMM.AT] Hash port svlan cos key */
    CTC_SCL_KEY_HASH_MAC,                               /**< [GB.GG.D2.TM.TMM.AT] Hash mac key */
    CTC_SCL_KEY_HASH_PORT_MAC,                          /**< [GB.GG.D2.TM.TMM.AT] Hash port mac key */
    CTC_SCL_KEY_HASH_IPV4,                              /**< [GB.GG.D2.TM.TMM.AT] Hash ipv4 key */
    CTC_SCL_KEY_HASH_PORT_IPV4,                         /**< [GB.GG.D2.TM.TMM.AT] Hash port ipv4 key */
    CTC_SCL_KEY_HASH_IPV6,                              /**< [GB.GG.D2.TM.TMM.AT] Hash ipv6 key */
    CTC_SCL_KEY_HASH_PORT_IPV6,                         /**< [GG.D2.TM.TMM.AT] Hash port ipv6 key */
    CTC_SCL_KEY_HASH_PORT_SVLAN_DSCP,                   /**< [TM.TMM.AT] Hash port svlan dscp key */
    CTC_SCL_KEY_HASH_SVLAN,                             /**< [D2.TM.TMM.AT] Hash svlan key */
    CTC_SCL_KEY_HASH_SVLAN_MAC,                         /**< [D2.TM.TMM.AT] Hash svlan mac key */
    CTC_SCL_KEY_HASH_LP_GRP,                            /**< [TMM.AT] Group dest logic port hash key */
    CTC_SCL_KEY_HASH_MD_ISOLATION_GRP,                  /**< [TMM.AT] Hash metadata isolation key */
    CTC_SCL_KEY_HASH_LOGIC_PORT,                        /**< [TMM.AT] Hash logic port key */
    CTC_SCL_KEY_HASH_CID_ISOLATION_GRP,                 /**< [TMM.AT] Hash cid isolation key */
    CTC_SCL_KEY_HASH_L2,                                /**< [GB.GG.D2.TM.TMM.AT] Hash layer 2 key */
    CTC_SCL_KEY_HASH_UDF,                               /**< [TMM.AT] Hash layer udf key */
    CTC_SCL_KEY_HASH_PORT_CROSS,                        /**< [D2.TM.TMM.AT] Hash port cross key */
    CTC_SCL_KEY_HASH_PORT_VLAN_CROSS,                   /**< [GG.D2.TM.TMM.AT] Hash port vlan cross key */
    CTC_SCL_KEY_HASH_NSH,                               /**< [AT] Hash nsh key */
    CTC_SCL_KEY_NUM
};
typedef enum ctc_scl_key_type_e ctc_scl_key_type_t;

#define  HASH_KEY

struct ctc_scl_hash_l2_field_sel_s
{
    uint8 mac_da;                   /**< [GG.D2.TM.TMM.AT] L2 key field Select MAC-DA */
    uint8 mac_sa;                   /**< [GG.D2.TM.TMM.AT] L2 key field Select MAC-SA */
    uint8 eth_type;                 /**< [GG.D2.TM.TMM.AT] L2 key field Select Ethernet type */
    uint16 class_id;                /**< [GG.D2.TM.TMM.AT] L2 key field Select class id */
    uint8 cos;                      /**< [GG.D2.TM.TMM.AT] L2 key field Select S-tag CoS */
    uint8 cfi;                      /**< [GG.D2.TM.TMM.AT] L2 key field Select S-tag CFI */
    uint8 vlan_id;                  /**< [GG.D2.TM.TMM.AT] L2 key field Select S-VLAN */
    uint8 tag_valid;                /**< [GG.D2.TM.TMM.AT] L2 key field Select S-tag exist */
    uint8 cvlan_id;                  /**< [TMM.AT] L2 key field Select C-VLAN */
};
typedef struct ctc_scl_hash_l2_field_sel_s ctc_scl_hash_l2_field_sel_t;

enum ctc_scl_hash_udf_flag_e
{
    CTC_SCL_HASH_UDF_FLAG_UDF   = 1U<<0,    /**< [TMM.AT] SCL flow hash with UDF */
    CTC_SCL_HASH_UDF_FLAG_UDF_AD_ID   = 1U<<1,    /**< [TMM.AT] SCL flow hash with UDF action id*/   
};
typedef enum ctc_scl_hash_udf_flag_e ctc_scl_hash_udf_flag_t;

struct ctc_scl_hash_udf_field_sel_s
{
    uint8  type;                        /**< [TMM.AT] UDF Hash Type: 0:L2, 1:L3  */

    uint8  udf_mask;                    /**< [TMM.AT] UDF key field Select UDF-MASK, bit0:0-15, bit1:16-31, ... */
    uint32 udf_id;                      /**< [TMM.AT] UDF key field Select UDF-ID  */
    uint32 flag;                        /**< [TMM.AT] UDF key field select flag, refer to ctc_scl_hash_udf_flag_t */

    ctc_scl_hash_l2_field_sel_t l2;     /**< [TMM.AT] UDF Hash L2 fields, refer to ctc_scl_hash_l2_field_sel_t */

    struct
    {
        uint8 l3_type;                  /**< [TMM.AT] UDF key field Select Layer3 Type */
        uint8 l4_type;                  /**< [TMM.AT] UDF key field Select Layer4 Type */
        uint8 ip_sa;                    /**< [TMM.AT] UDF key field Select IP SA, only for IPv4 */
        uint8 ip_da;                    /**< [TMM.AT] UDF key field Select IP DA, for IPv4 or IPv6 */
        uint8 l4_src_port;              /**< [TMM.AT] UDF key field Select Layer4 Source Port, only for IPv4 */
        uint8 l4_dst_port;              /**< [TMM.AT] UDF key field Select Layer4 Dest Port, only for IPv4 */
    }l3;
};
typedef struct ctc_scl_hash_udf_field_sel_s ctc_scl_hash_udf_field_sel_t;

struct ctc_scl_hash_field_sel_s
{
    uint32 field_sel_id;                    /**< [GG.D2.TM.TMM.AT] Field Select Id */

    /*action*/
    uint8  key_type;                        /**< [GG.D2.TM.TMM.AT] Refer CTC_SCL_KEY_HASH_L2 |CTC_SCL_KEY_HASH_UDF  */
    union
    {
        ctc_scl_hash_l2_field_sel_t   l2;   /**< [GG.D2.TM.TMM.AT] L2 key field select */
        ctc_scl_hash_udf_field_sel_t  udf;  /**< [TMM.AT] L2-UDF, L3-UDF, L2-Pkt, L3-Pkt or L4-Pkt key field select */
    }u;

};
typedef struct ctc_scl_hash_field_sel_s ctc_scl_hash_field_sel_t;


#define  TCAM_KEY



#define ACTION
enum ctc_scl_vlan_domain_e
{
    CTC_SCL_VLAN_DOMAIN_SVLAN,      /**< [GB.GG.D2.TM.TMM.AT] svlan domain */
    CTC_SCL_VLAN_DOMAIN_CVLAN,      /**< [GB.GG.D2.TM.TMM.AT] cvlan domain */
    CTC_SCL_VLAN_DOMAIN_UNCHANGE,   /**< [GB.GG.D2.TM.TMM.AT] keep unchange */
    CTC_SCL_VLAN_DOMAIN_MAX
};
typedef enum ctc_scl_vlan_domain_e ctc_scl_vlan_domain_t;


/**
 @brief [GB.GG] define acl vlan edit operation
*/
struct ctc_scl_vlan_edit_s
{
    uint8  stag_op;         /**< [GB.GG.D2.TM.TMM.AT] operation type of stag, see CTC_VLAN_TAG_OP_XXX  */
    uint8  svid_sl;         /**< [GB.GG.D2.TM.TMM.AT] select type of svid, see CTC_VLAN_TAG_SL_XXX  */
    uint8  scos_sl;         /**< [GB.GG.D2.TM.TMM.AT] select type of scos, see CTC_VLAN_TAG_SL_XXX  */
    uint8  scfi_sl;         /**< [GB.GG.D2.TM.TMM.AT] select type of scfi, see CTC_VLAN_TAG_SL_XXX  */
    uint16 svid_new;        /**< [GB.GG.D2.TM.TMM.AT] new svid, valid only if svid_sl is CTC_VLAN_TAG_OP_REP|CTC_VLAN_TAG_OP_REP_OR_ADD|CTC_VLAN_TAG_OP_ADD*/
    uint8  scos_new;        /**< [GB.GG.D2.TM.TMM.AT] new scos, valid only if scos_sl is CTC_VLAN_TAG_OP_REP|CTC_VLAN_TAG_OP_REP_OR_ADD|CTC_VLAN_TAG_OP_ADD*/
    uint8  scfi_new;        /**< [GB.GG.D2.TM.TMM.AT] new scfi, valid only if scfi_sl is CTC_VLAN_TAG_OP_REP|CTC_VLAN_TAG_OP_REP_OR_ADD|CTC_VLAN_TAG_OP_ADD*/

    uint8  ctag_op;         /**< [GB.GG.D2.TM.TMM.AT] operation type of ctag, see CTC_VLAN_TAG_OP_XXX */
    uint8  cvid_sl;         /**< [GB.GG.D2.TM.TMM.AT] select type of cvid, see CTC_VLAN_TAG_SL_XXX */
    uint8  ccos_sl;         /**< [GB.GG.D2.TM.TMM.AT] select type of ccos, see CTC_VLAN_TAG_SL_XXX */
    uint8  ccfi_sl;         /**< [GB.GG.D2.TM.TMM.AT] select type of ccfi, see CTC_VLAN_TAG_SL_XXX */
    uint16 cvid_new;        /**< [GB.GG.D2.TM.TMM.AT] new cvid, valid only if cvid_sl is CTC_VLAN_TAG_OP_REP|CTC_VLAN_TAG_OP_REP_OR_ADD|CTC_VLAN_TAG_OP_ADD*/
    uint8  ccos_new;        /**< [GB.GG.D2.TM.TMM.AT] new ccos, valid only if ccos_sl is CTC_VLAN_TAG_OP_REP|CTC_VLAN_TAG_OP_REP_OR_ADD|CTC_VLAN_TAG_OP_ADD*/
    uint8  ccfi_new;        /**< [GB.GG.D2.TM.TMM.AT] new ccfi, valid only if ccfi_sl is CTC_VLAN_TAG_OP_REP|CTC_VLAN_TAG_OP_REP_OR_ADD|CTC_VLAN_TAG_OP_ADD*/

    uint8  vlan_domain;     /**< [GB.GG.D2.TM.TMM.AT] refer ctc_scl_vlan_domain_t. [ingress] */
    uint8  tpid_index;      /**< [GB.GG.D2.TM.TMM.AT] svlan tpid index, if set 0xff, tpid disable*/

};
typedef struct ctc_scl_vlan_edit_s ctc_scl_vlan_edit_t;


struct ctc_scl_query_s
{
    uint32  group_id;       /**< [GB.GG.D2.TM.TMM.AT] [in]     SCL group ID*/
    uint32  entry_size;     /**< [GB.GG.D2.TM.TMM.AT] [in]     The maximum number of entry IDs to return. If 0, the number of entries is returned*/
    uint32* entry_array;    /**< [GB.GG.D2.TM.TMM.AT] [in|out] A pointer to a memory buffer to hold the array of IDs*/
    uint32  entry_count;    /**< [GB.GG.D2.TM.TMM.AT] [out]    Number of entries returned or. if entry_size  is 0, the number of entries available.*/
    uint16  pp_bmp;         /**< [AT] Pipeline bitmap */
};
typedef struct ctc_scl_query_s ctc_scl_query_t;

enum ctc_scl_bind_type_e
{
    CTC_SCL_BIND_TYPE_PORT,          /**< [GB.GG.D2.TM.TMM.AT] Port bind */
    CTC_SCL_BIND_TYPE_VLAN,          /**< [GB.GG.D2.TM.TMM.AT] Vlan bind */
    CTC_SCL_BIND_TYPE_IPV4SA,        /**< [GB.GG.D2.TM.TMM.AT] Ipv4-SA bind */
    CTC_SCL_BIND_TYPE_IPV4SA_VLAN,   /**< [GB.GG.D2.TM.TMM.AT] Ipv4-SA and Vlan bind */
    CTC_SCL_BIND_TYPE_MACSA,         /**< [GB.GG.D2.TM.TMM.AT] MAC-SA bind */
    CTC_SCL_BIND_TYPE_MAX            /**< [GB.GG.D2.TM.TMM.AT] Max bind type */
};
typedef enum ctc_scl_bind_type_e ctc_scl_bind_type_t;

struct ctc_scl_bind_s
{
    ctc_scl_bind_type_t type;        /**< [GB.GG.D2.TM.TMM.AT] refer ctc_scl_bind_type_t */
    mac_addr_t          mac_sa;      /**< [GB.GG.D2.TM.TMM.AT] MAC-SA */
    uint32              ipv4_sa;     /**< [GB.GG.D2.TM.TMM.AT] Ipv4-SA */
    uint32              gport;       /**< [GB.GG.D2.TM.TMM.AT] Global port */
    uint16              vlan_id;     /**< [GB.GG.D2.TM.TMM.AT] VLAN ID*/
};
typedef struct ctc_scl_bind_s ctc_scl_bind_t;

struct ctc_scl_aps_s
{
    uint16   protected_vlan;         /**< [GB.GG.D2.TM.TMM.AT] Protected vlan */
    uint16   aps_select_group_id;    /**< [GB.GG.D2.TM.TMM.AT] APS select group id*/
    uint8    is_working_path;        /**< [GB.GG.D2.TM.TMM.AT] is working path */
    uint8    protected_vlan_valid;   /**< [GB.GG.D2.TM.TMM.AT] Protected vlan valid */
};
typedef struct ctc_scl_aps_s ctc_scl_aps_t;

struct ctc_scl_vpls_s
{
    uint8 mac_limit_en;             /**< [GB] Enable mac limit */
    uint8 learning_en;              /**< [GB.D2.TM.TMM.AT] Enable learning */
};
typedef struct ctc_scl_vpls_s ctc_scl_vpls_t;

struct ctc_scl_logic_port_s
{
    uint16 logic_port;                      /**< [GB.GG.D2.TM.TMM.AT] Logic port */
    uint8  logic_port_type;                 /**< [GB.GG.D2.TM.TMM.AT] If set, indicates logic port horizon split. Used for VPLS. */
    uint8  binding_en;                      /**< [TMM.AT] If set, indicates binding logic_port */
};
typedef struct ctc_scl_logic_port_s ctc_scl_logic_port_t;

enum ctc_scl_offset_base_type_e
{
    CTC_SCL_OFFSET_BASE_TYPE_L2,           /**< [GG.D2.TM.TMM.AT] Start offset type is layer2 */
    CTC_SCL_OFFSET_BASE_TYPE_L3,           /**< [GG.D2.TM.TMM.AT] Start offset type is layer3 */
    CTC_SCL_OFFSET_BASE_TYPE_L4,           /**< [GG.D2.TM.TMM.AT] Start offset type is layer4 */
    CTC_SCL_OFFSET_BASE_TYPE_MAX
};
typedef enum ctc_scl_offset_base_type_e ctc_scl_offset_base_type_t;

struct ctc_scl_force_decap_s
{
    uint8  force_decap_en;          /**< [GG.D2.TM.TMM.AT] Enable force decap */
    uint8  offset_base_type;        /**< [GG.D2.TM.TMM.AT] Start offset type; refer to ctc_scl_offset_base_type_t */
    uint8  ext_offset;              /**< [GG.D2.TM.TMM.AT] Extend offset */
    uint8  payload_type;            /**< [GG.D2.TM.TMM.AT] Packet payload type; refer to packet_type_t*/
    uint8  use_outer_ttl;           /**< [TM.TMM.AT] Update outer ttl */
};
typedef struct ctc_scl_force_decap_s ctc_scl_force_decap_t;

#include "ctc_scl_frz.h"

/** @brief  scl group type */
enum ctc_scl_group_type_e
{
    CTC_SCL_GROUP_TYPE_NONE,         /**< [GG.D2.TM.TMM.AT]Do not care about group type. */
    CTC_SCL_GROUP_TYPE_GLOBAL,       /**< [GB.GG.D2.TM.TMM.AT] Global scl, mask ports. */
    CTC_SCL_GROUP_TYPE_PORT,         /**< [GB.GG.D2.TM.TMM.AT] Port scl, care gport. (GB)only for vlan key. */
    CTC_SCL_GROUP_TYPE_PORT_CLASS,   /**< [GB.GG.D2.TM.TMM.AT] A port class scl is against a class(group) of port*/
    CTC_SCL_GROUP_TYPE_LOGIC_PORT,   /**< [GB.GG.D2.TM.TMM.AT] Logic Port scl, care logic_port. */
    CTC_SCL_GROUP_TYPE_HASH,         /**< [GB.GG.D2.TM.TMM.AT] Hash group. */
    CTC_SCL_GROUP_TYPE_MAX
};
typedef enum ctc_scl_group_type_e ctc_scl_group_type_t;

enum ctc_scl_qos_map_flag_e
{
    CTC_SCL_QOS_MAP_FLAG_PRIORITY_VALID       = 1U << 0,  /**< [D2.TM.TMM.AT] Priority valid*/
    CTC_SCL_QOS_MAP_FLAG_DSCP_VALID           = 1U << 1,  /**< [D2.TM.TMM.AT] Dscp valid*/
    CTC_SCL_QOS_MAP_FLAG_TRUST_COS_VALID      = 1U << 2,  /**< [D2.TM.TMM.AT] Trust COS valid*/
};
typedef enum ctc_scl_qos_map_flag_e ctc_scl_qos_map_flag_t;

/** @brief  scl group info */
struct ctc_scl_qos_map_s
{
    uint32  flag;                   /**< [D2.TM.TMM.AT] QoS map flag, refer to ctc_scl_qos_map_flag_t*/
    uint8   priority;               /**< [D2.TM.TMM.AT] New Priority of All Color */
    uint8   color;                  /**< [D2.TM.TMM.AT] New Color*/
    uint8   dscp;                   /**< [D2.TM.TMM.AT] New DSCP */
    uint8   trust_dscp;             /**< [D2.TM.TMM.AT] Trust DSCP */
    uint8   trust_cos;              /**< [D2.TM.TMM.AT] Trust COS; 0: trust stag cos, 1: trust ctag cos */
    uint8   cos_domain;             /**< [D2.TM.TMM.AT] QoS COS domain */
    uint8   dscp_domain;            /**< [D2.TM.TMM.AT] QoS DSCP domain */
};
typedef struct ctc_scl_qos_map_s ctc_scl_qos_map_t;

/** @brief scl arp action */
#if 0
struct ctc_scl_arp_s
{
    uint8  self_addr;           /**< [TMM.AT] If set, it means arp target ip is local */
    uint8  excp_type;           /**< [TMM.AT] Arp exception type, refer to ctc_exception_type_t */
};
typedef struct ctc_scl_arp_s ctc_scl_arp_t;
#endif
/** @brief scl efd action type */
enum ctc_scl_efd_e
{
    CTC_SCL_EFD_NONE = 0,        /**< [TMM.AT] Do nothing */
    CTC_SCL_EFD_ENABLE,          /**< [TMM.AT] Enable efd hash lookup */
    CTC_SCL_EFD_DISABLE,         /**< [TMM.AT] Disable efd hash lookup */
    CTC_SCL_EFD_ELEPHANT_FLOW    /**< [TMM.AT] Identif as elephant flow.  */
};
typedef enum ctc_scl_efd_e ctc_scl_efd_t;

/** @brief scl policer action type */
enum ctc_scl_plc_e
{
    CTC_SCL_PLC_NONE,       /**< [TMM.AT] Do nothing */
    CTC_SCL_PLC_SERVICE,    /**< [TMM.AT] Service policer */
    CTC_SCL_PLC_SVC,        /**< [TMM.AT] SVC policer */
    CTC_SCL_PLC_NUM
};
typedef enum ctc_scl_plc_e ctc_scl_plc_t;

struct ctc_scl_flex_edit_s
{
    uint16 start_offset;             /**< [TMM.AT] start offset of origin data, uint:Bytes*/
    uint16 len;                      /**< [TMM.AT] edit length which use for insert or delete, unit: Bytes */
    uint8  start_offset_type;        /**< [TMM.AT] Start offset type; refer to ctc_scl_offset_base_type_t */
};
typedef struct ctc_scl_flex_edit_s ctc_scl_flex_edit_t;

enum ctc_scl_field_action_type_e
{

    CTC_SCL_FIELD_ACTION_TYPE_PENDING ,                 /**< [D2.TM.TMM.AT] Action change to pending for installed entry, used for Update all action */

    CTC_SCL_FIELD_ACTION_TYPE_DISCARD ,                 /**< [D2.TM.TMM.AT] DisCard Packet of All Color. */
    CTC_SCL_FIELD_ACTION_TYPE_STATS ,                   /**< [D2.TM.TMM.AT] Packet Statistics; data0: Stats Id. */
    CTC_SCL_FIELD_ACTION_TYPE_VLAN_EDIT,                /**< [D2.TM.TMM.AT] Vlan Edit;ext_data: ctc_scl_vlan_edit_t. */
    CTC_SCL_FIELD_ACTION_TYPE_CANCEL_ALL,               /**< [D2.TM.TMM.AT] Reset to default action */

    CTC_SCL_FIELD_ACTION_TYPE_COPY_TO_CPU ,             /**< [D2.TM.TMM.AT] Copy To Cpu. */
    CTC_SCL_FIELD_ACTION_TYPE_REDIRECT ,                /**< [D2.TM.TMM.AT] Redirect Packet with NHID; data0: Nexthop Id, data1: vlan filter enable (1-enable, 0-disable). */

    CTC_SCL_FIELD_ACTION_TYPE_FID ,                     /**< [D2.TM.TMM.AT] Fid; data0: fid. */
    CTC_SCL_FIELD_ACTION_TYPE_VRFID ,                   /**< [D2.TM.TMM.AT] Vrf id; data0: Vrfid. data1: Vrfid loop enable. */
    CTC_SCL_FIELD_ACTION_TYPE_POLICER_ID ,              /**< [D2.TM.TMM.AT] policer id; data0: Policer Id. data1: Policer type, refer to ctc_scl_plc_t */
    CTC_SCL_FIELD_ACTION_TYPE_COS_HBWP_POLICER,         /**< [D2.TM.TMM.AT] HBWP Policer with cos index; data0: Policer Id; data1: cos index*/
    CTC_SCL_FIELD_ACTION_TYPE_SRC_CID ,                 /**< [D2.TM.TMM.AT] Source Category id; data0: source cid value */
    CTC_SCL_FIELD_ACTION_TYPE_DST_CID ,                 /**< [D2.TM.TMM.AT] Destination Category id; data0: dest cid value */
    CTC_SCL_FIELD_ACTION_TYPE_SPAN_FLOW,                /**< [D2.TM.TMM.AT] The packet is span Flow,and it won't be mirrored again. */
    CTC_SCL_FIELD_ACTION_TYPE_REDIRECT_PORT,            /**< [D2.TM.TMM.AT] Redirect Packet to single port*/
    CTC_SCL_FIELD_ACTION_TYPE_QOS_MAP,                  /**< [D2.TM.TMM.AT] Qos map, ext_data: refer to ctc_scl_qos_map_t */
    CTC_SCL_FIELD_ACTION_TYPE_IGMP_SNOOP_EN,            /**< [TMM.AT] Igmp snooping enable */
    CTC_SCL_FIELD_ACTION_TYPE_EFD,                      /**< [TMM.AT] Efd action, data0: ctc_scl_efd_t */
    CTC_SCL_FIELD_ACTION_TYPE_UDF_ID,                   /**< [TMM.AT] Select a new udf id */
    CTC_SCL_FIELD_ACTION_TYPE_HMAC_ID,                  /**< [TMM] HMAC id, data0: hmac id */
    CTC_SCL_FIELD_ACTION_TYPE_LOCAL_ARP,                /**< [TMM.AT] Arp target ip is local ip */
    CTC_SCL_FIELD_ACTION_TYPE_CHANGE_LKUP_PRI,          /**< [TMM.AT] Change the Group priority of ctc_scl_group_info_t,
                                                             4 parallel lookup is support, default use group priority: hash0 > hash1 > tcam2 > tcam3
                                                             here range of lookup priority is 0~3, if scl hit, lkup priority will instead of group priority */
    CTC_SCL_FIELD_ACTION_TYPE_IPV4_BASED_L2MC,          /**< [TM.TMM.AT] Force MAC DA Lookup to IPv4 Lookup, data0: 0-disable, 1-enable */
    CTC_SCL_FIELD_ACTION_TYPE_IPV6_BASED_L2MC,          /**< [TMM.AT] Force MAC DA Lookup to IPv6 Lookup, data0: 0-disable, 1-enable */
    CTC_SCL_FIELD_ACTION_TYPE_IPFIX_LKUP_BY_OUTER_HEAD, /**< [TMM.AT] Ipfix use outer info. data0: outer info */
    CTC_SCL_FIELD_ACTION_TYPE_RANDOM_LOG,               /**< [TMM.AT] Random Log, the Destination is config by mirror; ext_data: ctc_acl_log_t */

    /*only valid for Ingress Action*/
    CTC_SCL_FIELD_ACTION_TYPE_LOGIC_PORT ,              /**< [D2.TM.TMM.AT] Logic Port; ext_data: ctc_scl_logic_port_t. */
    CTC_SCL_FIELD_ACTION_TYPE_USER_VLANPTR ,            /**< [D2.TM.TMM.AT] User VlanPtr; data0: User VlanPtr */
    CTC_SCL_FIELD_ACTION_TYPE_APS  ,                    /**< [D2.TM.TMM.AT] Aps Group; ext_data: ctc_scl_aps_t. */
    CTC_SCL_FIELD_ACTION_TYPE_ETREE_LEAF,               /**< [D2.TM.TMM.AT] VPLS Etree Leaf. */
    CTC_SCL_FIELD_ACTION_TYPE_STP_ID ,                  /**< [D2.TM.TMM.AT] Stp Id; data0: Stp Id. */
    CTC_SCL_FIELD_ACTION_TYPE_PTP_CLOCK_ID,             /**< [D2.TM.TMM.AT] Ptp Clock Id; data0: ptp clock id. */
    CTC_SCL_FIELD_ACTION_TYPE_SERVICE_ID,               /**< [D2.TM.TMM.AT] Service Id; data0: service id. */
    CTC_SCL_FIELD_ACTION_TYPE_SERVICE_ACL_EN,           /**< [D2.TM] Service acl enable. */
    CTC_SCL_FIELD_ACTION_TYPE_LOGIC_PORT_SECURITY_EN,   /**< [D2.TM.TMM.AT] Logic port security enable. */
    CTC_SCL_FIELD_ACTION_TYPE_BINDING_EN,               /**< [D2.TM.TMM.AT] Enable binding; ext_data: ctc_scl_bind_t */
    CTC_SCL_FIELD_ACTION_TYPE_MAC_LIMIT_DISCARD_EN,     /**< [D2] Enable mac limit discard */
    CTC_SCL_FIELD_ACTION_TYPE_OAM,                      /**< [D2.TM.TMM.AT] Enable OAM, data0: vpls oam using 0 and vpws oam using 1, data1: l2vpn_oam_id (only effective for vpws)*/
    CTC_SCL_FIELD_ACTION_TYPE_ROUTER_MAC_MATCH,         /**< [TM.TMM.AT] Set Router MAC Match, data0: enable use1 and disable use 0 */
    CTC_SCL_FIELD_ACTION_TYPE_MAC_LIMIT,                /**< [TM.TMM.AT] Logic port mac limit discard or to cpu, ext_data: ctc_maclimit_action_t */
    CTC_SCL_FIELD_ACTION_TYPE_LOGIC_PORT_TYPE,          /**< [TM.TMM.AT] Set logic port type */
    CTC_SCL_FIELD_ACTION_TYPE_ISOLATION_ID,             /**< [AT] Set isolation id*/
    CTC_SCL_FIELD_ACTION_TYPE_L3IF_PROPERTY,            /**< [AT] Set Overlay l3if property, data0:ctc_l3if_property_t, data1: l3if_id, ext_data: value*/

    CTC_SCL_FIELD_ACTION_TYPE_METADATA ,                /**< [D2.TM.TMM.AT] Metadata; data0: meta data. */
    CTC_SCL_FIELD_ACTION_TYPE_DENY_BRIDGE ,             /**< [D2.TM.TMM.AT] Deny Bridge. */
    CTC_SCL_FIELD_ACTION_TYPE_DENY_LEARNING ,           /**< [D2.TM.TMM.AT] Deny Learning. */
    CTC_SCL_FIELD_ACTION_TYPE_DENY_ROUTE ,              /**< [D2.TM.TMM.AT] Deny Route. */
    CTC_SCL_FIELD_ACTION_TYPE_FORCE_BRIDGE ,            /**< [D2.TM.TMM.AT] Force Bridge. */
    CTC_SCL_FIELD_ACTION_TYPE_FORCE_LEARNING ,          /**< [D2.TM.TMM.AT] Force Learning. */
    CTC_SCL_FIELD_ACTION_TYPE_FORCE_ROUTE ,             /**< [D2.TM.TMM.AT] Forece Route. */
    CTC_SCL_FIELD_ACTION_TYPE_ACL_TCAM_EN ,             /**< [D2.TM] Enable acl flow tcam lookup; ext_data: ctc_acl_property_t. */
    CTC_SCL_FIELD_ACTION_TYPE_ACL_HASH_EN ,             /**< [D2.TM] Enable acl flow hash lookup; ext_data: ctc_acl_property_t. */
    CTC_SCL_FIELD_ACTION_TYPE_FLOW_LKUP_BY_OUTER_HEAD , /**< [D2.TM.TMM.AT] Acl user outer info. data0: outer info */
    CTC_SCL_FIELD_ACTION_TYPE_FORCE_DECAP,              /**< [D2.TM.TMM.AT] Force decap */
    CTC_SCL_FIELD_ACTION_TYPE_SNOOPING_PARSER,          /**< [TM.TMM.AT] Snooping parser without decap, ext_data: ctc_scl_snooping_parser_t */
    CTC_SCL_FIELD_ACTION_TYPE_LB_HASH_SELECT_ID,        /**< [TM.TMM.AT] Load balance hash select id, refer to ctc_lb_hash_config_t, data0: sel_id<0-7>, 0 means disable */

    CTC_SCL_FIELD_ACTION_TYPE_DROP_UNKNOWN_UCAST ,      /**< [D2.TM.TMM.AT] Drop unknown ucast packet */
    CTC_SCL_FIELD_ACTION_TYPE_DROP_UNKNOWN_MCAST ,      /**< [D2.TM.TMM.AT] Drop unknown mcast packet */
    CTC_SCL_FIELD_ACTION_TYPE_DROP_BCAST ,              /**< [D2.TM.TMM.AT] Drop bcast packet */
    CTC_SCL_FIELD_ACTION_TYPE_DROP_KNOWN_UCAST ,        /**< [D2.TM.TMM.AT] Drop known ucast packet */
    CTC_SCL_FIELD_ACTION_TYPE_DROP_KNOWN_MCAST ,        /**< [D2.TM.TMM.AT] Drop known mcast packet */
    CTC_SCL_FIELD_ACTION_TYPE_VNI,                      /**< [TMM.AT] Virtual network ID */
    CTC_SCL_FIELD_ACTION_TYPE_ESLB,                     /**< [TMM.AT] EVPN EsLabel */
    CTC_SCL_FIELD_ACTION_TYPE_DOT1AE_CHAN_ID,           /**< [TMM] Dot1ae macsec channel, data0: Channel ID, ext_data: clear tag type, ref to ctc_dot1ae_clear_tag_type_t */
    CTC_SCL_FIELD_ACTION_TYPE_FLEX_EDIT,                /**< [TMM.AT] Flex Edit; ext_data: ref to ctc_scl_flex_edit_t. */

    CTC_SCL_FIELD_ACTION_TYPE_CANCEL_LKUP_BMP,          /**< [TMM.AT] Cancel 4 parallel lookup bitmap, bit0~bit3 indacate every lookup for hash0,hash1,tcam2,tcam3 */
    CTC_SCL_FIELD_ACTION_TYPE_XDATA,                    /**< [AT] xdata */
    CTC_SCL_FIELD_ACTION_TYPE_ARP_ACTION,               /**< [TMM.AT] arp packet action type, data0: ref to ctc_exception_type_t*/
    CTC_SCL_FIELD_ACTION_TYPE_NUM = 96
};
typedef enum ctc_scl_field_action_type_e ctc_scl_field_action_type_t;

/** @brief  scl entry struct */
struct ctc_scl_entry_s
{
    uint32 entry_id;                /**< [GB.GG.D2.TM.TMM.AT] scl entry id. */

    ctc_scl_key_t key;              /**< [GB.GG.D2.TM] scl key struct, [D2.TM.TMM.AT]only used when mode equal 0 for compatible mode */
    ctc_scl_action_t action;        /**< [GB.GG.D2.TM] scl action struct, [D2.TM.TMM.AT]only used when mode equal 0 for compatible mode */
    uint8 key_type;                 /**< [D2.TM.TMM.AT] ctc_scl_key_type_t,CTC_SCL_KEY_XXX */
    uint8 action_type;              /**< [D2.TM.TMM.AT] ctc_scl_action_type_t,CTC_SCL_ACTION_XXX */
    uint8 resolve_conflict;         /**< [D2.TM.TMM.AT] resolve conflict, install to tcam*/
    uint8  priority_valid;          /**< [GB.GG.D2.TM.TMM.AT] scl entry prioirty valid. if not valid, use default priority */
    uint32 priority;                /**< [GB.GG.D2.TM.TMM.AT] scl entry priority. 0-0xffffffff */
    uint8  mode;                    /**< [D2.TM.TMM.AT] 0, use sturct to install key and action; 1, use field to install key and action */
    uint8  hash_field_sel_id;       /**< [D2.TM.TMM.AT] hash select id, only used for scl flow l2 hash key */
    uint16 pp_bmp;                  /**< [AT] Pipeline bitmap scl, care pipeline. */
};
typedef struct ctc_scl_entry_s ctc_scl_entry_t;

/** @brief  scl group info */
struct ctc_scl_group_info_s
{
    uint8 type;                     /**< [GB.GG.D2.TM.TMM.AT] CTC_SCL_GROUP_TYPE_XXX*/
    uint8 lchip;                    /**< [GB.GG.D2.TM.TMM.AT] Local device id. only for ctc_scl_get_group_info.*/
    uint8 priority;                 /**< [GB.GG.D2.TM.TMM.AT] install_group ignore this. Group priority 0-3. [GB.GG.D2] only support priority 0-1 */
    union
    {
        uint16 port_class_id;       /**< [GB.GG.D2.TM.TMM.AT] port class id. multiple ports can share same un.un.port_class_id. for GB <1~61>. */
        uint32 gport;               /**< [GB.GG.D2.TM.TMM.AT] global_port, include linkagg */
        uint16 logic_port;          /**< [GB.GG.D2.TM.TMM.AT] Logic port */
    }un;
};
typedef struct ctc_scl_group_info_s ctc_scl_group_info_t;

typedef struct ctc_scl_kset_s {
    uint32 w[CTC_B2W_SIZE(CTC_FIELD_KEY_NUM)];
} ctc_scl_kset_t;

struct ctc_scl_flex_key_s
{
    uint8  key_type;              /**< [AT] new key type */
    uint8  origin_key_type;       /**< [AT] origin key type, refer to ctc_scl_key_type_t*/
    uint8  dir;                   /**< [AT] direction, refer to ctc_direction_t */
    uint8  udf_bmp;               /**< [AT] udf bitmap(in half word) */
    uint8  mode;                  /**< [AT] key mode, refer to ctc_field_flex_key_mode_t */
    uint32 flex_bits;             /**< [AT][out] flex key bits*/
    ctc_scl_kset_t kset;          /**< [AT] scl flex key fields */
    ctc_xdata_t* xdata;           /**< [AT] local xdata, only valid for CTC_FIELD_KEY_XDATA */
};
typedef struct ctc_scl_flex_key_s ctc_scl_flex_key_t; 

struct ctc_scl_field_action_s
{
    uint32 type;                            /**< [D2.TM.TMM.AT] Action Field type, CTC_SCL_ACTION_FIELD_TYPE_XXX. */

    uint32 data0;                           /**< [D2.TM.TMM.AT] Action Field data0 (uint32). */
    uint32 data1;                           /**< [D2.TM.TMM.AT] Action Field data1 (uint32). */
    void*  ext_data;                        /**< [D2.TM.TMM.AT] Action Field data (void*). */
};
typedef struct ctc_scl_field_action_s ctc_scl_field_action_t;

/** @brief  scl entry2 struct */
struct ctc_scl_entry2_s
{
    uint32 entry_id;                        /**< [D2.TM.TMM.AT] scl entry id. */

    uint8 key_type;                         /**< [D2.TM.TMM.AT] ctc_scl_key_type_t,CTC_SCL_KEY_XXX */
    uint8 action_type;                      /**< [D2.TM.TMM.AT] ctc_scl_action_type_t,CTC_SCL_KEY_XXX */
    uint8  priority_valid;                  /**< [D2.TM.TMM.AT]  scl tcam entry prioirty valid. if not valid, use default priority */
    uint32 priority;                        /**< [D2.TM.TMM.AT]  scl tcam entry priority. 0-0xffffffff */
    uint16 pp_bmp;                          /**< [AT] Pipeline bitmap scl, care pipeline. */
    uint16 klist_num;                       /**< [D2.TM.TMM.AT] Key field list number, vaild for p_key_list. */
    uint16 alist_num;                       /**< [D2.TM.TMM.AT] Action field list number, vaild for p_action_list. */
    ctc_field_key_t* p_key_list;            /**< [D2.TM.TMM.AT] Key field list. */
    ctc_scl_field_action_t* p_action_list;  /**< [D2.TM.TMM.AT] Action field list. */
};
typedef struct ctc_scl_entry2_s ctc_scl_entry2_t;

struct ctc_scl_default_action_s
{
    uint32 gport;                           /**< [GB.GG.D2.TM.TMM.AT] Global port */

    uint8  mode;                            /**< [D2.TM.TMM.AT] scl default ad mode, mode 0 use struct to set default ad and mode 1 use field to set default ad */
    uint8  dir;                             /**< [D2.TM.TMM.AT] default action type */
    uint8  scl_id;                          /**< [TM.TMM.AT] scl id, use 1 to set hash 1 default action */
    uint8  remove_en;                       /**< [TM.TMM.AT] add or remove field action, valid only in field mode*/
    ctc_scl_action_t action;                /**< [GB.GG.D2.TM] scl action struct */
    ctc_scl_field_action_t* field_action;   /**< [D2.TM.TMM.AT] scl field action */
};
typedef struct ctc_scl_default_action_s ctc_scl_default_action_t;

struct ctc_scl_snooping_parser_s
{
    uint8  enable;                  /**< [TM.TMM.AT] Enable snooping parser */
    uint8  start_offset_type;       /**< [TM.TMM.AT] Start offset type; refer to ctc_scl_offset_base_type_t */
    uint8  ext_offset;              /**< [TM.TMM.AT] Extend offset */
    uint8  payload_type;            /**< [TM.TMM.AT] Packet payload type; refer to packet_type_t*/
    uint8  use_inner_hash_en;       /**< [TM.TMM.AT] If set, do inner hash for unknown packet */
};
typedef struct ctc_scl_snooping_parser_s ctc_scl_snooping_parser_t;

#ifdef __cplusplus
}
#endif

#endif

